/*****************************************************************************************
This file is a part of Arise library.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

Arise Engine		SceneObject.cpp

					E-mail:	arise_engine@mail.ru

					Origin by DK Engine 0.019:
					dev (avon.dn.ua@gmail.com), Agressor (agress0r@mail.ru)

created:			10.09.2005
last changes:		12.09.2007
**************************************************************/
#include "stdafx.h"


SceneObject::SceneObject()
{
	m_type			= SCENE_OBJECT_TYPE_UNKNOWN;
	m_parent_type	= SCENE_OBJECT_TYPE_UNKNOWN;
}
SceneObject::~SceneObject()
{
}


void SceneObject::Init()
{
}


void SceneObject::Update()
{

}


void SceneObject::Release()
{
}


void SceneObject::Attach(SceneObject* child)
{
	if(!child) return;

	//log(14, "SceneObject %s Attach %s", GetNameCStr(), scene_object->GetNameCStr());

	//...
	//...scene_object->m_transformation_node.SetTransformation(???);
	
	child->m_parent_type = m_type;

	m_children.push_back(child);

}


void SceneObject::Detach(SceneObject* child)
{
	if(!child) return;

	for(	std::vector<SceneObject*>::iterator it = m_children.begin(); 
			it != m_children.end();
			it++)
	{
			if((*it) && (*it) == child)
			{
				(*it) = 0;
			}
	}
}


void SceneObject::ApplyTransformation(const D3DXMATRIXA16 &transformation)
{
	if(m_type == SCENE_OBJECT_TYPE_GRAFIC_OBJECT)
	{
		GraphicObject* graphic_object = (GraphicObject*) this;
		graphic_object->ApplyTransformation(transformation);
		return;
	}

	m_transformation_node.SetTransformation(transformation);
}


